package org.csc.sss.core.repository;

import org.csc.sss.core.model.Person;
import org.csc.sss.core.vo.PersonSysUserVO;
import org.csc.sss.core.vo.UserRoleVO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface PersonRepository extends JpaRepository<Person, String>, JpaSpecificationExecutor<Person>{
	

	@Query(value = "SELECT new map(u.id, u.nickname, u.email, r.roleId) "
			+ "FROM SysUser u, SysUserRole r where u.id = r.userId")
	List<Map<String, Object>> findUserRoleVOList();


	@Query(value = "select p.id,p.name,p.`type`,p.address,p.age  from person p LEFT JOIN sys_user u on p.user_id = u.id", nativeQuery = true)
	List<Map<String, Object>> selectList();



}
